package com.jdk18.inter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by xuyiwei on 2018/7/9.
 */
public class LambdaTest {

    public static void main(String[] args) {

        DefalutTest dt = (a, b) -> a+b;
        System.out.println(  dt.sub(1,2));

        DefalutTest dt1 = (a, b) -> {
            return a+b;
        };
        System.out.println(  dt.sub(1,2));

        LambdaInterTest lit = () ->{
            System.out.println("有很多参数");
        };

        lit.print();

        LambdaTest2 lt1 = aa-> System.out.println("jdk8新特性:"+aa);
        lt1.print("有一个参数");


        //改写为：
        LambdaTest2 lt2 = System.out::println;
        lt2.print("实例引用方式调用");



        List<Integer> list = new ArrayList<Integer>();
        list.add(50);
        list.add(18);
        list.add(6);
        list.add(99);
        list.add(32);
        System.out.println(list.toString()+"排序之前");
        Collections.sort(list);
//        LambdaTest3 lt3 = Collections::sort;
//        lt3.sort(list, (c,d) -> {
//            return c-d;
//        });
        System.out.println(list.toString()+"排序之后");



//        LambdaTest4 lambdaTest4 = LambdaTest1::add;
//        LambdaTest1 lct = new LambdaTest1();
//        System.out.println(lct.add( 5, 8));
    }
}
